package org.hdax.dm.rest.service;

import org.hdax.dm.dao.entitydao.DmItemTypeDao;
import org.hdax.dm.entity.item_type.DmItemType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RestItemTypeService {
    @Autowired
    private DmItemTypeDao dmItemTypeDao;

    @PostMapping(path = "/findAll")
    public List<DmItemType> findAll() {
        return dmItemTypeDao.findAll();
    }

    @PostMapping(path = "/findByParent")
    public List<DmItemType> findByParent(@RequestParam("parent") Integer parent) {
        return dmItemTypeDao.findByParentOrderByKey(parent);
    }
}
